<?php
/*
 * Created on Dec 2, 2010
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 
class CouponDomain
{
	public $id;
	public $merchantId;
	
	public $code;
	
	public $name;
	public $filteredName;
	
	public $descript;
	
	public $trackingURL;	
	public $trackingHtmlCode;
	
	public $linkCodeJavascript;
	
	public $impressionpixel;
	
	public $startDate;
	public $endDate;
	public $createDate;
	
	public $sourceId;
	
	public $costType;	// 0:unknown, 1:CPA, 2:CPC, 3:CPM
	public $creativeType;
	
	public $status;
	
	public $createdTime;
	public $modifiedTime;
	
	public $isFeatured;
	public $isRecommend;
	
	public $r_sortValue;
	
	public $r_couponTypeStr;
	public $r_validDateStr;
	public $r_validDateTypeStr;
	
	
	public $oMerchant;
	public $oCouponImage;
	
	public $oAttributes;
	public $oComments;
	
	public $oCategory;
	public $oVote;
	
		
	public function setId($id)
	{
		$this->id = $id;
	}
	
	public function getId()
	{
		return $this->id;
	}
	
	public function setMerchantId($merchantId)
	{
		$this->merchantId = $merchantId;
	}
	
	public function getMerchantId()
	{
		return $this->merchantId;
	}
	
	public function setDescript($descript)
	{
		$this->descript = $descript;
	}
	
	public function getDescript()
	{
		return $this->descript;
	}
	
	public function setCode($code)
	{
		$this->code = $code;
	}
	
	public function getCode()
	{
		return $this->code;
	}
	
	public function setName($name)
	{
		$this->name = $name;
	}
	
	public function getName()
	{
		return $this->name;
	}
	
	public function setFilteredName($filteredname)
	{
		$this->filteredname = $filteredname;
	}
	
	public function getFilteredName()
	{
		return $this->filteredname;
	}
	
	public function setTrackingURL($trackingURL)
	{
		$this->trackingURL = $trackingURL;
	}
	
	public function getTrackingURL()
	{
		return $this->trackingURL;
	}
	
	public function setStartDate($startDate)
	{
		$this->startDate = $startDate;
	}
	
	public function getStartDate()
	{
		return $this->startDate;
	}
	
	public function setEndDate($endDate)
	{
		$this->endDate = $endDate;
	}
	
	public function getEndDate()
	{
		return $this->endDate;
	}
	
	public function setCreateDate($createDate)
	{
		$this->createDate = $createDate;
	}
	
	public function getCreateDate()
	{
		return $this->createDate;
	}
	
	public function setTrackingHtmlCode($trackingHtmlCode)
	{
		$this->trackingHtmlCode = $trackingHtmlCode;
	}
	
	public function getTrackingHtmlCode()
	{
		return $this->trackingHtmlCode;
	}
	
	public function setImpressionpixel($impressionpixel)
	{
		$this->impressionpixel = $impressionpixel;
	}
	
	public function getImpressionpixel()
	{
		return $this->impressionpixel;
	}	
	
	public function setSourceId($sourceId)
	{
		$this->sourceId = $sourceId;
	}
	
	public function getSourceId()
	{
		return $this->sourceId;
	}
	
	public function setCreativeType($creativeType)
	{
		$this->creativeType = $creativeType;
	}

	public function setCostType($costType)
	{
		$this->costType = $costType;
	}
		
	public function setIsFeatured($isFeatured)
	{
		$this->isFeatured = $isFeatured;
	}

	public function setIsRecommend($isRecommend)
	{
		$this->isRecommend = $isRecommend;
	}
		
	public function getCreativeType()
	{
		return $this->creativeType;
	}

	public function getCostType()
	{
		return $this->costType;
	}

	public function getIsFeatured()
	{
		return $this->isFeatured;
	}

	public function getIsRecommend()
	{
		return $this->isRecommend;
	}
	
	public function setMerchant($oMerchant)
	{
		$this->oMerchant = $oMerchant;
	}
	
	public function getMerchant()
	{
		return $this->oMerchant;
	}
	
	public function setCouponImage($oCouponImage)
	{
		$this->oCouponImage = $oCouponImage;
	}
	
	public function getCouponImage()
	{
		return $this->oCouponImage;
	}
	
	public function setAttributes($oAttributes)
	{
		$this->oAttributes = $oAttributes;
	}
	
	public function getAttributes()
	{
		return $this->oAttributes;
	}
	
	public function setComments($oComments)
	{
		$this->oComments = $oComments;
	}
	
	public function getComments()
	{
		return $this->oComments;
	}
	
	public function setStatus($status)
	{
		$this->status = $status;
	}	
	public function getStatus()
	{
		return $this->status;
	}
	
	public function setCreatedTime($createdTime)
	{
		$this->createdTime = $createdTime;
	}	
	public function getCreatedTime()
	{
		return $this->createdTime;
	}
	
	public function setModifiedTime($modifiedTime)
	{
		$this->modifiedTime = $modifiedTime;
	}	
	public function getModifiedTime()
	{
		return $this->modifiedTime;
	}
	
	public function setRsortValue($r_sortValue)
	{
		$this->r_sortValue = $r_sortValue;
	}
	
	public function getRsortValue()
	{
		return $this->r_sortValue;
	}
	
	
	public function getAttributeValue($attributeId)
	{
		if(is_object($this->oAttributes[$attributeId])){
			return $this->oAttributes[$attributeId]->getAttributeValue();
		}else
			return '';
	}
	
	public function getDisplayCouponType()
	{
		if(empty($this->r_couponTypeStr)){		
			if(is_array($this->oAttributes)){
				foreach($this->oAttributes as $oAttribute){
					//get free shipping(2), price cut(35), free gift(37), Sweepstakes(38), Free Gift Wrap(39), buy x get y(40)
					if($oAttribute->getAttributeId() == 2 || $oAttribute->getAttributeId() == 35 || $oAttribute->getAttributeId() == 37 
					 || $oAttribute->getAttributeId() == 38 || $oAttribute->getAttributeId() == 39 || $oAttribute->getAttributeId() == 40){
						if(empty($this->r_couponTypeStr))
							$this->r_couponTypeStr = $oAttribute->getAttributeName();
						else
							$this->r_couponTypeStr .= ',' . $oAttribute->getAttributeName();
					}
				}
			}
		}

		return $this->r_couponTypeStr;
	}
	
	public function getValidDateStr()
	{
		if(!empty($this->r_validDateStr))
			return $this->r_validDateStr;
		
		$startDate 	= '';
		$endDate 	= '';
		
		if(!empty($this->startDate)){
			$startDate = date('m-d-Y', strtotime($this->startDate));
		}
		
		if(!empty($this->endDate)){
			$endDate = date('m-d-Y', strtotime($this->endDate));
		}
		
		if(empty($endDate)){
			if(!empty($startDate)){
				$this->r_validDateStr = 'Offer valid on ' . $startDate . ' or later';
			}
		}else{
			if(empty($startDate)){
				$this->r_validDateStr = 'Expires on ' . $endDate;
			}else{
				$this->r_validDateStr = 'Offer valid from ' . $startDate . ' through ' . $endDate;
			}
		}
		
		return $this->r_validDateStr;
	}
	
	public function getValidDateTypeStr()
	{
		if(!empty($this->r_validDateTypeStr))
			return $this->r_validDateTypeStr;
		
		$typestr = $this->getDisplayCouponType();
		$datestr = $this->getValidDateStr();
		
		if(empty($typestr)){
			return $datestr;
		}else{		
			if(empty($datestr))
				return $typestr;
			else{
				return ($typestr . ', ' . $datestr);
			}
		}
	}
	
	public function getMailto()
	{
		if(empty($this->code))
			return "subject=I%27ve%20shared%20a%20" . rawurlencode($this->oMerchant->getName()) . "%20coupon%20with%20you%20from%20www.hohobb.com!&amp;body=" . 
			rawurlencode($this->oMerchant->getName()) . "%20Coupon%3A%20" . rawurlencode($this->name) . "%0D%0A%0D%0AShare%20URL%3A%20http%3A%2F%2Fwww.hohobb.com%2Fcoupons%2F" 
			. $this->id;
		else
			return "subject=I%27ve%20shared%20a%20" . rawurlencode($this->oMerchant->getName()) . "%20coupon%20with%20you%20from%20www.hohobb.com!&amp;body=" . 
				rawurlencode($this->oMerchant->getName()) . "%20Coupon%3A%20" . rawurlencode($this->name) . ", Coupon Code: " . $this->code . 
				"%0D%0A%0D%0AShare%20URL%3A%20http%3A%2F%2Fwww.hohobb.com%2Fcoupons%2F" . $this->id;
	}
	
	public function getShareFacebook($homeURL)
	{
		if(empty($this->code))
			return "http://www.facebook.com/sharer.php?u=" . "$homeURL/coupons/" . $this->id . "&t=" . rawurlencode($this->oMerchant->getName() . ' coupon ' . $this->name);
		else
			return "http://www.facebook.com/sharer.php?u=" . "$homeURL/coupons/" . $this->id . "&t=" . rawurlencode($this->oMerchant->getName() . ' coupon ' . $this->name . ', Coupon Code: ' . $this->code);
	}
	
	public function getShareTwitter($homeURL)
	{
		if(empty($this->code))
			return "http://twitter.com/intent/tweet?url=" . "$homeURL/coupons/" . $this->id . "&text=" . rawurlencode($this->oMerchant->getName() . ' coupon ' . $this->name);
		else
			return "http://twitter.com/intent/tweet?url=" . "$homeURL/coupons/" . $this->id . "&text=" . rawurlencode($this->oMerchant->getName() . ' coupon ' . $this->name . ', Coupon Code: ' . $this->code);
	}
	
	public function setCategory($oCategory)
	{
		$this->oCategory = $oCategory;
	}
	
	public function getCategory()
	{
		return $this->oCategory;
	}
	
	public function setVote($oVote)
	{
		$this->oVote = $oVote;
	}
	
	public function getVote()
	{
		return $this->oVote;
	}
}
?>
